'use strict';

const user = require('./controller/user');
const Router = require('koa-router');
// default route as apiV1
// const apiV1 = config.app.isProd ? '/api/v1' : ''

const router = new Router({ prefix: '/api/v1' });
// sign
// router.get('/login', sign.showLogin)

// router.post('/logout', auth.userRequired, sign.logout)

// user
// router.get('/users/profile', auth.userRequired, user.showProfile)
// admin
// '/user' 使用 admin 中间件
// router.use('/admin', auth.userRequired, auth.adminRequired)
// router.get('/admin/users/:id', filter.list, user.list)
router.post('/admin/users', user.create);
router.get('/admin/users/list', user.list);
router.put('/admin/users/:id', user.update);
router.get('/admin/users/:id', user.find);
router.delete('/admin/users/:id', user.remove);

router.get('/_error', function * () {
  // this.unda()
  let exit = this.query.exit;
  if (exit) process.exit(1);
  throw new Error('is test _error');
});
module.exports = router;
